package jizh3;
import dao.logDao;
import util.MybatisSessionFactoy;
@Controller
public class user {
 @requestMapping(value="/register.action",method=requestMethod.POST)
 @@ResponseBody
 public String registear(
		 @RequestParam(value="account",defaultValue="")String account
		 @RequestParam(value="password",defaultValue="")String password)
 {
	 SqlSession Session=MybatisSessionFactory.getSqlSession();
	 UsersDao dao = Session.getMapper(UsersDao.class);
	 Map<String,Object>result = dao.queryone(account);
	 if("1".equals(result.get("counter").toString()));
	 {
		 return "ERR";
	 }
	 dao.add(account,password,"2016-07-14");
	 Session.commit();
	 Map<String,Object> lastId = dao.lastId();
	 LogDao dao2 = Session.getMapper(Logdao.class);
	 dao2.insert(last.get("id").toString(),"0","注册","2016-07-14","17:20:20");
	 Session.commit();
	 return "OK";
	 
 @RequestMapping(value=/"login.action",method=RequestMethod.POST)
 @ResponseBody
 public String login(
		 @requestParam(value="account",defaultValue="")String account,
		 @requestparam(value ="password",defultValue="")String password
		 HttpServletResponse response
		 ){
	 SqlSession Session=MybatisSessionFactory.getSqlSession();
	 UsersDao dao=Session.getMapper(usersDao.class);
	 Map<String,Object>result=dao.querry(account,password);
	 Session.close();
	 if("0".equals(result.get("count").toString()))
	 {
		 return "ERR";
	 }
	 reaponse.addCookie(new Cookie("result",result.get("id").toString()));
	 return "OK";
 }
 @Request Mapper(value="/query_")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

